﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Configuration;
using StructureMap;

namespace Repository
{
    public class RepositoryManager
    {
        public static void Register(Database context)
        {
            ObjectFactory.Initialize(x =>
            {
                x.For<UserRepository>().Use<UserRepository>().Ctor<Database>().Is(context);
                x.For<CategoryRepository>().Use<CategoryRepository>().Ctor<Database>().Is(context);
                x.For<ProductRepository>().Use<ProductRepository>().Ctor<Database>().Is(context);
            });
        }

        public static UserRepository CreateUserRepository()
        {
            return ObjectFactory.GetInstance<UserRepository>();
        }

        public static CategoryRepository CreateCategoryRepository()
        {
            return ObjectFactory.GetInstance<CategoryRepository>();
        }

        public static ProductRepository CreateProductRepository()
        {
            return ObjectFactory.GetInstance<ProductRepository>();
        }
    }
}
